;var module = angular.module('CtrlsContent');
module.controller('TongguanDDCtrl',['$scope','api_other',function($scope,api_other){
	$scope.DD = {};
	$scope.DD.count = 1;
	$scope.DD.price = localStorage.price;
	$scope.DD.share_price = localStorage.share_price;
	$scope.IsShare =localStorage.IsShare;
	$scope.id = localStorage.goods_id;

	$scope.total = $scope.DD.price;
	$scope.payMoney = $scope.total;
	$scope.youhui = $scope.DD.price-$scope.DD.share_price;
	$scope.event = {
		minus:function(){
			$scope.DD.count--;
			if($scope.DD.count<=1)
				$scope.DD.count = 1;
			if(localStorage.IsShare == 2){
				$scope.payMoney = $scope.DD.share_price*$scope.DD.count
			}else{
				$scope.payMoney = $scope.DD.price*$scope.DD.count
			}
			$scope.total = $scope.DD.price*$scope.DD.count;
		},
		add:function(){
			$scope.DD.count++;
			if(localStorage.IsShare == 2){
				$scope.payMoney = $scope.DD.share_price*$scope.DD.count
			}else{
				$scope.payMoney = $scope.DD.price*$scope.DD.count
			}
			$scope.total = $scope.DD.price*$scope.DD.count;
		},
		submit:function(){
			if(!($scope.DD.consignee && $scope.DD.tel && $scope.DD.address)){
				alert('请填写完整收货信息');
				return ;
			}
			var obj  = {
				userId:localStorage.bls_userId,
				goods_id:localStorage.goods_id,
				IsShare:localStorage.IsShare,
				count:$scope.DD.count,
				consignee:$scope.DD.consignee,
				tel:$scope.DD.tel,
				address:$scope.DD.address
			};
			var promise = api_other.bookDingDan(obj);
			promise.success(function(data){
				if(data.returnCode == 0){
					
				}
			})
		}
	};
	if(localStorage.IsShare == 2){
		$scope.payMoney = $scope.DD.share_price;
	}
	//$scope.event.get();
}]);